<!--店铺协议页面-->
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div>
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item prop="type">
          <ren-select v-model="dataForm.type" dict-type="agreement_type"></ren-select>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('api:shopProtocol:save')" type="primary" @click="addOrUpdateHandle()">
            新增
          </el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('api:shopProtocol:delete')" type="danger" @click="deleteHandle()">
            删除
          </el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" stripe highlight-current-row
                @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle"
                style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="content" label="协议内容" header-align="center" align="center" width="" show-overflow-tooltip>
          <template slot-scope="{row}">
            <el-tag size="small" type="primary" style="cursor: pointer;" @click="showRichText(row.content)" v-if="row.content">点击查看</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="type" label="协议类型" header-align="center" align="center" sortable width="">
          <template slot-scope="{row,$index}">
            <el-tag v-if="row.type === 1" size="small" type="success">
              {{ $getDictLabel("agreement_type", row.type) }}
            </el-tag>
            <el-tag v-else size="small" type="info">{{
                $getDictLabel("agreement_type", row.type)
              }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="createDate" label="创建日期" header-align="center" align="center"></el-table-column>
        <el-table-column label="操作" fixed="right" header-align="center" align="center" width="">
          <template slot-scope="scope">
            <el-link v-if="$hasPermission('api:shopProtocol:update')" type="primary"
                       @click="addOrUpdateHandle(scope.row.id)">修改
            </el-link>
            <el-link v-if="$hasPermission('api:shopProtocol:delete')" type="primary"
                       @click="deleteHandle(scope.row.id)">删除
            </el-link>
          </template>
        </el-table-column>

      </el-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
                     layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
                     @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
      <!--富文本显示-->
      <com-rich-text :visible.sync="showRich" :content="content"></com-rich-text>
    </div>

  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './shopProtocolAddOrUpdate.vue'
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/api/shopProtocol/page',
        getDataListIsPage: true,
        deleteURL: '/api/shopProtocol',
        deleteIsBatch: true
      },
      showRich:false,                    //富文本显示
      content:"",                        //富文本内容
      dataForm: {
        id: '',                          //id
        type:'',                         //0服务协议1隐私协议
        content:'',                      //协议内容
      },
    }
  },
  components: {
    AddOrUpdate
  },
  created() {

  },
  methods: {
    //富文本显示
    showRichText(content){
      this.showRich=true;
      this.content= content;
    },
  }
}
</script>
<style lang="scss">
.ellipsis2 {
  /* //超出两行省略号 */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}
</style>
